/* ====================================================================
 * (#)Header: ListCommand.java
 * (#)Revision: 
 * (#)Date Created: June 11, 2009 12:07:22 AM
 * (#)Created By: Karol Wozniak
 * ====================================================================
 *
 * Copyright (c) 2007 karolak .  All rights reserved.
 *
 * ====================================================================
 * 
 * The software application represented here is the sole property of 
 * karolak. Its unauthorized utilization is expressly prohibited.
 * 
 * ====================================================================
 */
package com.karolak.web.saf.command;

import java.util.List;

import com.karolak.service.Service;
import com.karolak.web.saf.action.ModelAction;

/**
 * <code>ListCommand</code> is used to ....
 * 
 * @author <a href="mailto:kwozniak@hotmail.com">Karol Wozniak</a>
 */
public class ListCommand implements ActionCommand {

	public <T, Id, S extends Service<T, Id>> void prepare(ModelAction<T, Id, S> action) {

	}

	public <T, Id, S extends Service<T, Id>> void validate(ModelAction<T, Id, S> action) {

	}

	public <T, Id, S extends Service<T, Id>> String execute(ModelAction<T, Id, S> action) {
		List<T> list = action.getService().select();
		action.sort(list, action.getSortProperties());
		action.setEntities(list);
		return "list";
	}
}
